package com.lzh.gulimall.product.web;

import com.lzh.gulimall.product.service.SkuInfoService;
import com.lzh.gulimall.product.vo.SkuItemVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * @ClassName ItemController
 * @Description TODO
 * @Author liuzhihui
 * @Date 2020/8/29 23:32
 * @Version 1.0
 **/
@Controller
public class ItemController {
    @Autowired
    private SkuInfoService skuInfoService;

    /**
     *
     * index页面springmvc能自动访问，直接输入当前服务的ip:端口号就直接访问或者直接输入域名
     * 非index页面不能直接访问，需要做路径映射,可以通过写controller去映射，也能去配视图映射
     *
     * 当前sku详情
     * @param skuId
     * @return
     */
    @GetMapping("/{skuId}.html")
    public String skkuItem(@PathVariable("skuId") Long skuId, Model model){
        System.out.println("准备查询："+skuId+"详情");
        SkuItemVo skuItemVo=skuInfoService.item(skuId);
        model.addAttribute("item",skuItemVo);
        return "item";
    }


}
